package com.buss.core.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class JndiContext {

	public static Context ctx = null;

	public static Context getJndi() {
		Properties properties = new Properties();
		InputStream inputFile;
		inputFile = JndiContext.class
				.getResourceAsStream("jndicontext.properties");
		try {
			properties.load(inputFile);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if (ctx == null) {
			try {
				ctx = new InitialContext(properties);
			} catch (NamingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return ctx;
	}
}
